<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="css/test.css">
<title>login</title>
<script language="javascript">
function  goRegist()
{
	window.location.assign("/ImageTest/regist.jsp");
}

function validate()
{
	var username = document.getElementById("username_1").value;
	var password = document.getElementById("password_1").value;
	if(username == "" || password == "" || repassword == "")
	{
		alert("用户名或者密码不能为空！");
		return false;
	}
	return true;

}
</script>

</head>
<body>

<%! String currentUser = null; %>
<%
//判断是否已经有用户登录
	currentUser = (String)session.getAttribute("currentUser");
	if(null != currentUser)
	{
		out.print("<p id='welcomeInfo'> 当前登录用户："+currentUser+" <a href='/ImageTest/test.jsp'>退出当前用户</a></p>");
	}
	
%>

<!-- 判断用户名或者密码是否错误 -->
<%!String bLogin = null; %>
<%
	bLogin = (String)request.getAttribute("hasLogin");
	//System.out.println(bLogin);
%>
<%
if(bLogin != null){
	if("false".equals(bLogin)) {%>
<p id="first">用户名或者密码错误</p>
<%}
	else
	{%>
		<p id="first"><%=bLogin %></p>	
	<%}
}%>
<!-- 判断用户名或者密码是否错误 -->

<div id="header"></div>

<ul id="nav">
<li><a href="/ImageTest/index.jsp">首页</a></li>
<li><a href="/ImageTest/viewImage.jsp">看图片</a></li>
<li><a href="/ImageTest/upload_file.jsp">上传图片</a></li>
<li><a href="/ImageTest/login.jsp">登录</a></li>
<li><a href="/ImageTest/regist.jsp">注册用户</a></li>
<li><a href="/ImageTest/administor.jsp">管理员</a></li>
</ul>
<%
	//如果已经有用户登录，请先退出当前用户，在进行第二次登录
	if(null != currentUser)
	{
		out.print("用户"+ currentUser+"已经登录，请先退出当前登录");
		return;
	}
%>
<div id="content">
<form onsubmit="return validate()" action="login_svr" method="post">
<table id="content_table" align="center">
<tr>
<td>用户名:</td>
<td><input id="username_1" type="text"  name="username"></td>
<tr>
<td>密    码:</td>
<td><input id="password_1" type="password"  name="password"/></td>
</tr>
<tr>
<td><input type="submit"  name="submit" value="登陆"/></td>
<td><input type="reset"  name="reset" value="重置"/></td>
</tr>
</table>
</form>
</div>
<p id="last">如果没有注册,清单击按钮进入注册页面  <input type="button" value="regist" name="regist" onclick="goRegist()"></input></p>

</body>
</html>